﻿@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <form id="form" enctype="multipart/form-data">
            Name:<input id="objName" name="objName" type="text" />
            Image:<input name="objFile" class="MaxPic" data-params='{"Id":"0","CategoryCode":"McLaughlin","LimitCode":"aaaa"}' type="file" onchange="UploadFile(this);" />
            <input id="hid" type="hidden" value='{zoo:"zoo",bar:"bar",baz:"baz"}' />
            <input name="filepath" type="hidden" />
            <img class="MaxPic" src="#" alt="预览图" />
            <input type="button" id="btn_submit" value="提交" />
        </form>
    </div>
    <script src="~/Content/js/jquery-1.8.2.js"></script>
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/js/tjzheng.js"></script>
    <script type="text/javascript">
        $("#btn_submit").click(function () {
            var objFormEntity = new FormEntity("#form");
            objFormEntity.url = "/Files/Upload";
            objFormEntity.isClearData = false;
            objFormEntity.submit();
        });
        function UploadFile(file) {
            //var objForm = document.createElement('form');
            //$(objForm).append($(file));
            //$(objForm).attr("enctype", "multipart/form-data");
            //var objFormEntity = new FormEntity(objForm);

            var objFormEntity = new FormEntity("#form");
            objFormEntity.url = "/Files/SetUpload";
            //alert($(file).attr("data-params"));
            //objFormEntity.data = $(file).attr("data-params");
            objFormEntity.data = $("#hid").val();
            objFormEntity.contentType = "application/json";
            objFormEntity.isClearData = false;
            objFormEntity.submit();


            //var objZoo = JSON.parse($(this).attr("data-params"));
            //alert(objZoo.firstName);
            //var objAjaxEntity = new AjaxEntity();
            //objAjaxEntity.data = $(file).attr("data-params");
            //objAjaxEntity.contentType = "application/json";
            //objAjaxEntity.url = "/Files/SetUpload/";
            //objAjaxEntity.execute();
        }
    </script>
</body>
</html>
